using System;
using Medianamik.Core.DAL.Repositories;
using Medianamik.UI.Web.MVP.Presentation;
using Medianamik.UI.Web.MVP.View.UserControls;
using Medianamik.UI.Web.MVP;

namespace ProtegezVous.Modules.Presenters
{
    public class MedianamikGridPresenter : ModulePresenterWithRepository<IMedianamikGrid,
                                              INodeRepository>
    {
        public MedianamikGridPresenter(IMedianamikGrid view,
            INodeRepository nodeRepository)
            : base(view, nodeRepository)
        {
            View.LockRequestFailed += LockRequestFailed;
            View.ActivationStatusChanged += NodeActivationStatusChanged;
        }

        protected override void Initialize(object sender, EventArgs e)
        {

        }

        void LockRequestFailed(object sender, IdEventArgs e)
        {
            View.ShowLockInfoTooltip(e.Id);
        }

        void NodeActivationStatusChanged(object sender, ActivationStatusChangedEventArgs e)
        {
            Repository.SetActiveStatus(e.Id, e.Culture, e.Status);
        }
    }
}
